﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//import
using ddcCajamarca.BusinessLogic.Documentos.Service;
using Microsoft.Practices.Unity;
using ddcCajamarca.BusinessEntities.Documentos;
using System.Web.ModelBinding;

namespace ddcCajamarca.Web.Documentos
{
    public partial class frmTramite : System.Web.UI.Page
    { [Dependency]
        public ITDocumentarioBL tramiteBL { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            var accion = Request.QueryString["accion"];
            var id = Request.QueryString["id"];
            if (accion != null && accion == "nuevo")
            {
                fvTramite.DefaultMode = FormViewMode.Insert;
            }
            else if (accion != null && id != null && accion == "delete")
            {
                Int32 idTramite = Int32.Parse(id);
            }

        }
         public TDocumentario GetTramite([QueryString("id")] Int32? id)
        {
            if (id.HasValue)
                return tramiteBL.getFromTramiteDocumentarioById(id.Value);
            return null;
        }
         public void InsertTramite(TDocumentario tramitedocumentario)
         {
             if (ModelState.IsValid)
             {
                 tramiteBL.AddTramiteDocumentario(tramitedocumentario);
             }
             Response.Redirect("~/Documentos/frmListTramites.aspx");

         }
        public void UpdateTramite(TDocumentario tramitedocumentario)
        {

            if (ModelState.IsValid)
                tramiteBL.UpdateTramiteDocumentario(tramitedocumentario);
            Response.Redirect("~/Documentos/frmListTramites.aspx");
        }
    }
}
    
